home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 April: Mac OS SDK / Dev.CD Apr 00 SDK1.toast / Development Kits / Hardware / PowerManager DDK 1.0f1 / Interfaces&Libraries / Interfaces / Events.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-08  |  11.4 KB  |  396 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        Events.h
  3.  
  4.      Contains:    Event Manager Interfaces.
  5.  
  6.      Version:    Mac OS 8
  7.  
  8.      DRI:        Rich Wilkes
  9.  
  10.      Copyright:    © 1985-1999 by Apple Computer, Inc., all rights reserved
  11.  
  12.      Warning:    *** APPLE INTERNAL USE ONLY ***
  13.                  This file may contain unreleased API's
  14.  
  15.      BuildInfo:    Built by:            Scott Johnson
  16.                  On:                    10/8/99 11:26 AM
  17.                  With Interfacer:    3.0d13   (MPW PowerPC)
  18.                  From:                Events.i
  19.                      Revision:        72
  20.                      Dated:            2/27/99
  21.                      Last change by:    NG
  22.                      Last comment:    Update CarbonLib exportsets - add KeyTranslate
  23.  
  24.      Bugs:        Report bugs to Radar component "System Interfaces", "Latest"
  25.                  List the version information (from above) in the Problem Description.
  26.  
  27. */
  28. #ifndef __EVENTS__
  29. #define __EVENTS__
  30.  
  31. #ifndef __OSUTILS__
  32. #include <OSUtils.h>
  33. #endif
  34.  
  35. #ifndef __QUICKDRAW__
  36. #include <Quickdraw.h>
  37. #endif
  38.  
  39. #ifndef __MACTYPES__
  40. #include <MacTypes.h>
  41. #endif
  42.  
  43. #if !TARGET_OS_MAC || forCarbon
  44. #ifndef __ENDIAN__
  45. #include <Endian.h>
  46. #endif
  47.  
  48. #endif  /* !TARGET_OS_MAC || forCarbon */
  49.  
  50.  
  51.  
  52. #if PRAGMA_ONCE
  53. #pragma once
  54. #endif
  55.  
  56. #ifdef __cplusplus
  57. extern "C" {
  58. #endif
  59.  
  60. #if PRAGMA_IMPORT
  61. #pragma import on
  62. #endif
  63.  
  64. #if PRAGMA_STRUCT_ALIGN
  65.     #pragma options align=mac68k
  66. #elif PRAGMA_STRUCT_PACKPUSH
  67.     #pragma pack(push, 2)
  68. #elif PRAGMA_STRUCT_PACK
  69.     #pragma pack(2)
  70. #endif
  71.  
  72. typedef UInt16                             EventKind;
  73. typedef UInt16                             EventMask;
  74. enum {
  75.     nullEvent                    = 0,
  76.     mouseDown                    = 1,
  77.     mouseUp                        = 2,
  78.     keyDown                        = 3,
  79.     keyUp                        = 4,
  80.     autoKey                        = 5,
  81.     updateEvt                    = 6,
  82.     diskEvt                        = 7,
  83.     activateEvt                    = 8,
  84.     osEvt                        = 15,
  85.     kHighLevelEvent                = 23
  86. };
  87.  
  88. enum {
  89.     mDownMask                    = 1 << mouseDown,                /* mouse button pressed*/
  90.     mUpMask                        = 1 << mouseUp,                    /* mouse button released*/
  91.     keyDownMask                    = 1 << keyDown,                    /* key pressed*/
  92.     keyUpMask                    = 1 << keyUp,                    /* key released*/
  93.     autoKeyMask                    = 1 << autoKey,                    /* key repeatedly held down*/
  94.     updateMask                    = 1 << updateEvt,                /* window needs updating*/
  95.     diskMask                    = 1 << diskEvt,                    /* disk inserted*/
  96.     activMask                    = 1 << activateEvt,                /* activate/deactivate window*/
  97.     highLevelEventMask            = 0x0400,                        /* high-level events (includes AppleEvents)*/
  98.     osMask                        = 1 << osEvt,                    /* operating system events (suspend, resume)*/
  99.     everyEvent                    = 0xFFFF                        /* all of the above*/
  100. };
  101.  
  102. enum {
  103.     charCodeMask                = 0x000000FF,
  104.     keyCodeMask                    = 0x0000FF00,
  105.     adbAddrMask                    = 0x00FF0000,
  106.     osEvtMessageMask            = 0xFF000000
  107. };
  108.  
  109. enum {
  110.                                                                 /* OS event messages.  Event (sub)code is in the high byte of the message field.*/
  111.     mouseMovedMessage            = 0x00FA,
  112.     suspendResumeMessage        = 0x0001
  113. };
  114.  
  115. enum {
  116.     resumeFlag                    = 1,                            /* Bit 0 of message indicates resume vs suspend*/
  117.     convertClipboardFlag        = 2                                /* Bit 1 in resume message indicates clipboard change*/
  118. };
  119.  
  120.  
  121. typedef UInt16                             EventModifiers;
  122. enum {
  123.                                                                 /* modifiers */
  124.     activeFlagBit                = 0,                            /* activate? (activateEvt and mouseDown)*/
  125.     btnStateBit                    = 7,                            /* state of button?*/
  126.     cmdKeyBit                    = 8,                            /* command key down?*/
  127.     shiftKeyBit                    = 9,                            /* shift key down?*/
  128.     alphaLockBit                = 10,                            /* alpha lock down?*/
  129.     optionKeyBit                = 11,                            /* option key down?*/
  130.     controlKeyBit                = 12,                            /* control key down?*/
  131.     rightShiftKeyBit            = 13,                            /* right shift key down?*/
  132.     rightOptionKeyBit            = 14,                            /* right Option key down?*/
  133.     rightControlKeyBit            = 15                            /* right Control key down?*/
  134. };
  135.  
  136. enum {
  137.     activeFlag                    = 1 << activeFlagBit,
  138.     btnState                    = 1 << btnStateBit,
  139.     cmdKey                        = 1 << cmdKeyBit,
  140.     shiftKey                    = 1 << shiftKeyBit,
  141.     alphaLock                    = 1 << alphaLockBit,
  142.     optionKey                    = 1 << optionKeyBit,
  143.     controlKey                    = 1 << controlKeyBit,
  144.     rightShiftKey                = 1 << rightShiftKeyBit,
  145.     rightOptionKey                = 1 << rightOptionKeyBit,
  146.     rightControlKey                = 1 << rightControlKeyBit
  147. };
  148.  
  149. enum {
  150.     kNullCharCode                = 0,
  151.     kHomeCharCode                = 1,
  152.     kEnterCharCode                = 3,
  153.     kEndCharCode                = 4,
  154.     kHelpCharCode                = 5,
  155.     kBellCharCode                = 7,
  156.     kBackspaceCharCode            = 8,
  157.     kTabCharCode                = 9,
  158.     kLineFeedCharCode            = 10,
  159.     kVerticalTabCharCode        = 11,
  160.     kPageUpCharCode                = 11,
  161.     kFormFeedCharCode            = 12,
  162.     kPageDownCharCode            = 12,
  163.     kReturnCharCode                = 13,
  164.     kFunctionKeyCharCode        = 16,
  165.     kEscapeCharCode                = 27,
  166.     kClearCharCode                = 27,
  167.     kLeftArrowCharCode            = 28,
  168.     kRightArrowCharCode            = 29,
  169.     kUpArrowCharCode            = 30,
  170.     kDownArrowCharCode            = 31,
  171.     kDeleteCharCode                = 127,
  172.     kNonBreakingSpaceCharCode    = 202
  173. };
  174.  
  175.  
  176. struct EventRecord {
  177.     EventKind                         what;
  178.     UInt32                             message;
  179.     UInt32                             when;
  180.     Point                             where;
  181.     EventModifiers                     modifiers;
  182. };
  183. typedef struct EventRecord                EventRecord;
  184. typedef CALLBACK_API( void , FKEYProcPtr )(void );
  185. typedef STACK_UPP_TYPE(FKEYProcPtr)                             FKEYUPP;
  186. #if OPAQUE_UPP_TYPES
  187.     EXTERN_API(FKEYUPP)
  188.     NewFKEYUPP                       (FKEYProcPtr                userRoutine);
  189.  
  190.     EXTERN_API(void)
  191.     DisposeFKEYUPP                   (FKEYUPP                    userUPP);
  192.  
  193.     EXTERN_API(void)
  194.     InvokeFKEYUPP                   (FKEYUPP                    userUPP);
  195.  
  196. #else
  197.     enum { uppFKEYProcInfo = 0x00000000 };                             /* pascal no_return_value Func() */
  198.     #define NewFKEYUPP(userRoutine)                                 (FKEYUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppFKEYProcInfo, GetCurrentArchitecture())
  199.     #define DisposeFKEYUPP(userUPP)                                 DisposeRoutineDescriptor(userUPP)
  200.     #define InvokeFKEYUPP(userUPP)                                     CALL_ZERO_PARAMETER_UPP((userUPP), uppFKEYProcInfo)
  201. #endif
  202. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  203. #define NewFKEYProc(userRoutine)                                 NewFKEYUPP(userRoutine)
  204. #define CallFKEYProc(userRoutine)                                InvokeFKEYUPP(userRoutine)
  205. EXTERN_API( void )
  206. GetMouse                        (Point *                mouseLoc)                            ONEWORDINLINE(0xA972);
  207.  
  208. EXTERN_API( Boolean )
  209. Button                            (void)                                                        ONEWORDINLINE(0xA974);
  210.  
  211. EXTERN_API( Boolean )
  212. StillDown                        (void)                                                        ONEWORDINLINE(0xA973);
  213.  
  214. EXTERN_API( Boolean )
  215. WaitMouseUp                        (void)                                                        ONEWORDINLINE(0xA977);
  216.  
  217. EXTERN_API( UInt32 )
  218. TickCount                        (void)                                                        ONEWORDINLINE(0xA975);
  219.  
  220. EXTERN_API( UInt32 )
  221. KeyTranslate                    (const void *            transData,
  222.                                  UInt16                 keycode,
  223.                                  UInt32 *                state)                                ONEWORDINLINE(0xA9C3);
  224.  
  225. EXTERN_API( UInt32 )
  226. GetCaretTime                    (void)                                                        TWOWORDINLINE(0x2EB8, 0x02F4);
  227.  
  228.  
  229. /* 
  230.     QuickTime 3.0 supports GetKeys() on unix and win32
  231.     But, on little endian machines you will have to be
  232.     careful about bit numberings and/or use a KeyMapByteArray
  233.     instead.
  234. */
  235. #if TARGET_OS_MAC && !forCarbon
  236.  
  237. typedef UInt32                             KeyMap[4];
  238. #else
  239. typedef BigEndianLong                     KeyMap[4];
  240. #endif  /* TARGET_OS_MAC && !forCarbon */
  241.  
  242. typedef UInt8                             KeyMapByteArray[16];
  243. EXTERN_API( void )
  244. GetKeys                            (KeyMap                 theKeys)                            ONEWORDINLINE(0xA976);
  245.  
  246.  
  247. /* Obsolete event types & masks */
  248. enum {
  249.     networkEvt                    = 10,
  250.     driverEvt                    = 11,
  251.     app1Evt                        = 12,
  252.     app2Evt                        = 13,
  253.     app3Evt                        = 14,
  254.     app4Evt                        = 15,
  255.     networkMask                    = 0x0400,
  256.     driverMask                    = 0x0800,
  257.     app1Mask                    = 0x1000,
  258.     app2Mask                    = 0x2000,
  259.     app3Mask                    = 0x4000,
  260.     app4Mask                    = 0x8000
  261. };
  262.  
  263.  
  264. struct EvQEl {
  265.     QElemPtr                         qLink;
  266.     SInt16                             qType;
  267.     EventKind                         evtQWhat;                    /* this part is identical to the EventRecord as defined above */
  268.     UInt32                             evtQMessage;
  269.     UInt32                             evtQWhen;
  270.     Point                             evtQWhere;
  271.     EventModifiers                     evtQModifiers;
  272. };
  273. typedef struct EvQEl                    EvQEl;
  274. typedef EvQEl *                            EvQElPtr;
  275. typedef CALLBACK_API( void , GetNextEventFilterProcPtr )(EventRecord *theEvent, Boolean *result);
  276. typedef STACK_UPP_TYPE(GetNextEventFilterProcPtr)                 GetNextEventFilterUPP;
  277. #if OPAQUE_UPP_TYPES
  278.     EXTERN_API(GetNextEventFilterUPP)
  279.     NewGetNextEventFilterUPP       (GetNextEventFilterProcPtr userRoutine);
  280.  
  281.     EXTERN_API(void)
  282.     DisposeGetNextEventFilterUPP    (GetNextEventFilterUPP    userUPP);
  283.  
  284.     EXTERN_API(void)
  285.     InvokeGetNextEventFilterUPP       (EventRecord *            theEvent,
  286.                                     Boolean *                result,
  287.                                     GetNextEventFilterUPP    userUPP);
  288.  
  289. #else
  290.     enum { uppGetNextEventFilterProcInfo = 0x000000BF };             /* SPECIAL_CASE_PROCINFO(11) */
  291.     #define NewGetNextEventFilterUPP(userRoutine)                     (GetNextEventFilterUPP)NewRoutineDescriptor((ProcPtr)(userRoutine), uppGetNextEventFilterProcInfo, GetCurrentArchitecture())
  292.     #define DisposeGetNextEventFilterUPP(userUPP)                     DisposeRoutineDescriptor(userUPP)
  293.     #define InvokeGetNextEventFilterUPP(theEvent, result, userUPP)     CALL_TWO_PARAMETER_UPP((userUPP), uppGetNextEventFilterProcInfo, (theEvent), (result))
  294. #endif
  295. /* support for pre-Carbon UPP routines: NewXXXProc and CallXXXProc */
  296. #define NewGetNextEventFilterProc(userRoutine)                     NewGetNextEventFilterUPP(userRoutine)
  297. #define CallGetNextEventFilterProc(userRoutine, theEvent, result) InvokeGetNextEventFilterUPP(theEvent, result, userRoutine)
  298.  
  299. typedef GetNextEventFilterUPP             GNEFilterUPP;
  300. EXTERN_API( QHdrPtr )
  301. GetEvQHdr                        (void)                                                        THREEWORDINLINE(0x2EBC, 0x0000, 0x014A);
  302.  
  303. EXTERN_API( UInt32 )
  304. GetDblTime                        (void)                                                        TWOWORDINLINE(0x2EB8, 0x02F0);
  305.  
  306. EXTERN_API( void )
  307. SetEventMask                    (EventMask                 value)                                TWOWORDINLINE(0x31DF, 0x0144);
  308.  
  309.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  310.                                                                                             #pragma parameter __D0 PPostEvent(__A0, __D0, __A1)
  311.                                                                                             #endif
  312. EXTERN_API( OSErr )
  313. PPostEvent                        (EventKind                 eventCode,
  314.                                  UInt32                 eventMsg,
  315.                                  EvQElPtr *                qEl)                                TWOWORDINLINE(0xA12F, 0x2288);
  316.  
  317. EXTERN_API( Boolean )
  318. GetNextEvent                    (EventMask                 eventMask,
  319.                                  EventRecord *            theEvent)                            ONEWORDINLINE(0xA970);
  320.  
  321. EXTERN_API( Boolean )
  322. WaitNextEvent                    (EventMask                 eventMask,
  323.                                  EventRecord *            theEvent,
  324.                                  UInt32                 sleep,
  325.                                  RgnHandle                 mouseRgn) /* can be NULL */            ONEWORDINLINE(0xA860);
  326.  
  327. EXTERN_API( Boolean )
  328. EventAvail                        (EventMask                 eventMask,
  329.                                  EventRecord *            theEvent)                            ONEWORDINLINE(0xA971);
  330.  
  331.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  332.                                                                                             #pragma parameter __D0 PostEvent(__A0, __D0)
  333.                                                                                             #endif
  334. EXTERN_API( OSErr )
  335. PostEvent                        (EventKind                 eventNum,
  336.                                  UInt32                 eventMsg)                            ONEWORDINLINE(0xA02F);
  337.  
  338.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  339.                                                                                             #pragma parameter __D0 OSEventAvail(__D0, __A0)
  340.                                                                                             #endif
  341. EXTERN_API( Boolean )
  342. OSEventAvail                    (EventMask                 mask,
  343.                                  EventRecord *            theEvent)                            TWOWORDINLINE(0xA030, 0x5240);
  344.  
  345.                                                                                             #if TARGET_OS_MAC && TARGET_CPU_68K && !TARGET_RT_MAC_CFM
  346.                                                                                             #pragma parameter __D0 GetOSEvent(__D0, __A0)
  347.                                                                                             #endif
  348. EXTERN_API( Boolean )
  349. GetOSEvent                        (EventMask                 mask,
  350.                                  EventRecord *            theEvent)                            TWOWORDINLINE(0xA031, 0x5240);
  351.  
  352. EXTERN_API( void )
  353. FlushEvents                        (EventMask                 whichMask,
  354.                                  EventMask                 stopMask)                            TWOWORDINLINE(0x201F, 0xA032);
  355.  
  356. EXTERN_API( void )
  357. SystemClick                        (const EventRecord *    theEvent,
  358.                                  WindowPtr                 theWindow)                            ONEWORDINLINE(0xA9B3);
  359.  
  360. EXTERN_API( void )
  361. SystemTask                        (void)                                                        ONEWORDINLINE(0xA9B4);
  362.  
  363. EXTERN_API( Boolean )
  364. SystemEvent                        (const EventRecord *    theEvent)                            ONEWORDINLINE(0xA9B2);
  365.  
  366. #if OLDROUTINENAMES
  367. #define KeyTrans(transData, keycode, state) KeyTranslate(transData, keycode, state)
  368. #endif  /* OLDROUTINENAMES */
  369.  
  370. /* GetGlobalMouse is only available as part of the Carbon API*/
  371. EXTERN_API( void )
  372. GetGlobalMouse                    (Point *                globalMouse);
  373.  
  374.  
  375.  
  376. #if PRAGMA_STRUCT_ALIGN
  377.     #pragma options align=reset
  378. #elif PRAGMA_STRUCT_PACKPUSH
  379.     #pragma pack(pop)
  380. #elif PRAGMA_STRUCT_PACK
  381.     #pragma pack()
  382. #endif
  383.  
  384. #ifdef PRAGMA_IMPORT_OFF
  385. #pragma import off
  386. #elif PRAGMA_IMPORT
  387. #pragma import reset
  388. #endif
  389.  
  390. #ifdef __cplusplus
  391. }
  392. #endif
  393.  
  394. #endif /* __EVENTS__ */
  395.  
  396.